﻿function BindCheckBoxEvent(obj) {
    $("#cb_All").click(function() {
        var checked = $(this).attr("checked");
        $(":checkbox").attr("checked", checked);
        if (obj) {
            setButton(obj,checked);
        }
    });
    $(":checkbox").not("#cb_All").each(function() {
        $(this).click(function() {

            var lenAll = $(":checkbox").not("#cb_All").length;
            var lenChecked = $("input:checked").not("#cb_All").length;
            if (obj) {
                setButton(obj,lenChecked > 0 ? true : false);
            }

            $("#cb_All").attr("checked", lenChecked == lenAll ? true : false);
        });
    });
}
function setButton(obj,val) {
    if (val) {
        obj.removeAttr("disabled");
    }
    else {
        obj.attr("disabled", "disabled");
    }
}
function BindSearchSwitch() {
    $(".searchPanel img").toggle(
        function() {
            $(this).attr("src", rootpath + "images/searchpanelminus.jpg");
            $(".searchPanel div").slideDown(500);
        },
        function() {
            $(this).attr("src", rootpath + "images/searchpanelplus.jpg");
            $(".searchPanel div").slideUp(500);
        }
    );
    hideSearchPanel();
}

function formReady() {    
    $("#dv_loading").hide();
    $(".dataform,.DG").show();
    $(window.parent.document).find("iframe").height($(".adminMainContent").height() + 50);
}

function hideSearchPanel() {
    $(".searchPanel div").slideUp(500);
}

function facebox(msg) {
    window.parent.facebox(msg);
}